package net;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UdpReceiveThread implements Runnable {
    private DatagramSocket datagramSocket;
    public UdpReceiveThread(DatagramSocket datagramSocket) {
        this.datagramSocket = datagramSocket;
    }

    @Override
    public void run() {
        while (true) {
            byte[] bytes = new byte[1024];
            DatagramPacket datagramPacket = new DatagramPacket(bytes, bytes.length);
            try {
                datagramSocket.receive(datagramPacket);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            String ip = datagramPacket.getAddress().getHostAddress();
            int port = datagramPacket.getPort();
            byte[] data = datagramPacket.getData();

        }
    }
}
